package com.common.frame.base

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter

class FragmentPagerAdapter(
    fm: FragmentManager,
    private var fragments: MutableList<Fragment>,
    private var titles: MutableList<String>?
) : FragmentStatePagerAdapter(fm) {

    override fun getItem(position: Int): Fragment = fragments[position]

    override fun getCount(): Int = if (isNotEmpty(fragments)) fragments.size else 0

    override fun getPageTitle(position: Int): CharSequence? =
        if (isNotEmpty(titles)) titles?.get(position) else ""

}